undefined is a value assigned to a variable that has been declared but hasn't been assigned a value.
null is a value that represents the intentional absence of any object value.
If a function doesn't have a return statement, it returns undefined by default.
If you try to access an object property that doesn't exist, you get undefined
undefined + 1 = NaN (Not a Number): You can't add 'nothingness' to a number.
Optional Chaining: The Optional Chaining operator allows you to read a property deep within a chain of connected objects without having to manually check if each level exists.
It’s often used as a placeholder for an object that might be created later.
It’s used to clear the contents of a variable or property.
If you run typeof null, JavaScript returns 'object'.
It is the root type in prototype chain
In math, null is treated as 0.
Nullish Coalescing: The Nullish Coalescing operator is a logical operator that returns its right-hand side operand when its left-hand side operand is null or undefined.
If you call a function that doesn't return anything and assign its result to a variable, what will that variable contain? How does that differ from a variable you explicitly set to null?
When you read a property that doesn't exist on an object, what value do you get? What would you get if you had set that property to null instead?
Write a short snippet that checks whether a variable is undefined versus null before using it.
You receive a JSON payload where some fields may be missing, resulting in undefined, while others are explicitly null. How would you normalize these values before processing them?
A function expects a string but receives undefined, causing a runtime error. Walk me through how you would debug this and decide whether to treat undefined as null.
Explain why value == null matches both null and undefined, and when you would choose === instead.
Design a utility that safely extracts nested properties without throwing errors, handling both undefined and null. What design choices would you make and why?
When defining an API contract between front‑end and back‑end, how do you decide whether missing fields should be sent as undefined, null, or omitted? Discuss trade‑offs for type safety and serialization.
During a TypeScript migration you want to tighten nullability. How would you refactor existing JavaScript that mixes undefined and null to avoid subtle bugs?
Your organization is moving to a polyglot microservices architecture. How would you establish a consistent convention for representing absent values across services, and what impact does the null vs undefined distinction have on data contracts, logging, and monitoring?
You lead a team maintaining a legacy library used by many internal products, some of which check for undefined and others for null. How would you deprecate one pattern without breaking downstream consumers?